package com.zzptc.gyc.myapp;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.zzptc.lzh.myapp.R;

public class RegActivity extends AppCompatActivity {
    EditText yhm1;
    EditText mm1;
    EditText qrmm;
    Button cz;
    Button zc1;
    private static final String TAG = "RegActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_reg);
        initView();
        event();
    }
    public void initView(){
        yhm1=findViewById(R.id.yhm1);
        mm1=findViewById(R.id.mm1);
        qrmm=findViewById(R.id.qrmm);
        cz=findViewById(R.id.cz);
        zc1=findViewById(R.id.zc1);
    }
    public void event(){
        yhm1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(RegActivity.this, "请输入用户名", Toast.LENGTH_SHORT).show();
            }
        });
        mm1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(RegActivity.this, "请输入密码", Toast.LENGTH_SHORT).show();
            }
        });
        qrmm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(RegActivity.this, "再次输入密码", Toast.LENGTH_SHORT).show();
            }
        });
        cz.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(RegActivity.this, "重置完成", Toast.LENGTH_SHORT).show();
            }
        });
        zc1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                //准备回传，1.获取值 2.保存到意图 3.回传
                String username = yhm1.getText().toString().trim();
                String password = mm1.getText().toString().trim();
                if (username.equals("")||password.equals("")){
                    Toast.makeText(RegActivity.this, "用户名不能为空或密码不能为空", Toast.LENGTH_SHORT).show();
                }else {
                    Log.d(TAG, "username");
                    Toast.makeText(RegActivity.this, username + "注册成功", Toast.LENGTH_SHORT).show();
                    Intent intent1 = new Intent();
                    intent1.putExtra("name", username);
                    intent1.putExtra("password", password);
                    setResult(2, intent1);
                    finish();
                }
            }
        });
    }

}
